import yaml


# 读取yaml文件，返回yaml内容
def load_yaml(path):
    file = open(path, 'r', encoding='utf-8') # 编译时 允许utf-8格式
    data = yaml.load(file, Loader=yaml.FullLoader)
    return data


# 写入内容到yaml文件中
def write_yaml(data, path):
    # file = open(path,'w',encoding='utf-8')
    # yaml.dump(data,file,allow_unicode=True)
    with open(path, 'w') as f:
        yaml.dump(data, f, allow_unicode=True) # allow_unicode: 防止出现中文乱码


# if __name__ == '__main__':
#     print(load_yaml('../data/demo.yaml'))
